import request from '@/uilts/request'
// 用户登录请求
export const LoginRequest = ({ username, password }) => {
  console.log(username, password)
  return request({
    url: '/user/login',
    method: 'POST',
    data: {
      username,
      password
    }
  })
}
// 获取用户信息
export const UserResRequest = () => {
  return request({
    url: '/user'
  })
}
// 用户登出
export const UserLogoutquest = () => {
  return request({
    url: '/user/logout',
    method: 'POST'
  })
}
// 轮播图
export const SwiperRequest = () => {
  return request({
    url: '/home/swiper'
  })
}
// 租房小组
export const RentalRequest = () => {
  return request({
    url: '/home/groups'
  })
}
// 城市区域
export const RegionRequest = (code) => {
  return request({
    url: '/area',
    params: {
      id: code
    }
  })
}
// 子级城市
export const SublevelRequest = (code) => {
  return request({
    url: '/area',
    params: {
      id: code
    }
  })
}
// 房屋信息
export const HouseRequest = ({ NewHouse, RentalMode, Money, roomType, oriented, floor, start, end }) => {
  console.log(NewHouse, RentalMode, Money, roomType, oriented, floor, start, end)
  return request({
    url: '/houses',
    params: {
      cityId: NewHouse,
      rentType: RentalMode || null,
      price: Money || null,
      roomType: roomType || null,
      oriented: oriented || null,
      floor: floor || null,
      start: start || null,
      end: end || null
    }
  })
}
// 城市选择列表
export const ChoiceCityRequest = (id) => {
  return request({
    url: '/area/city',
    params: {
      level: id
    }
  })
}
// 热门城市
export const HotCityRequest = () => {
  return request({
    url: '/area/hot'
  })
}
// 房屋详细信息
export const HouseMesgRequest = (id) => {
  return request({
    url: `/houses/${id}`
  })
}
// 房屋发布，条件
export const HouseReleaseRequest = () => {
  return request({
    url: '/houses/params'
  })
}
// 查询房源数据
export const HousingSourceRequest = (id) => {
  return request({
    url: '/area/map',
    params: {
      id
    }
  })
}
// 小区关键词搜索
export const CellKeywordsRequest = ({ name, id }) => {
  return request({
    url: '/area/community',
    params: {
      name,
      id
    }
  })
}
// 发布房源
export const SubmitRequest = ({ title, description, houseImg, oriented, supporting, price, roomType, size, floor, community, tempSlides }) => {
  console.log(title, description, houseImg, oriented, supporting, price, roomType, size, floor, community, tempSlides)
  return request({
    url: '/user/houses',
    method: 'POST',
    data: {
      // 标题a
      title: title || null,
      // 描述a
      description: description || null,
      // 图片a
      houseImg: houseImg || null,
      // 朝向a
      oriented: oriented || null,
      // 房屋的配置，冰箱，衣柜a
      supporting: supporting || null,
      // 价格a
      price: price || null,
      // 户型a
      roomType: roomType || null,
      // 面积a
      size: size || null,
      // 楼层a
      floor: floor || null,
      // 该房屋地址a
      community: community || null,
      tempSlides: tempSlides || null
    }
  })
}
// 上传图片
export const UploadImgRequest = (file) => {
  return request({
    url: '/houses/image',
    method: 'POST',
    data: {
      file
    },
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
// 收藏房屋
export const StarHouseRequest = (id, model) => {
  return request({
    url: `/user/favorites/${id}`,
    method: `${model}`,
    data: {
      id
    }
  })
}
// 收藏列表
export const StarHouseListRequest = () => {
  return request({
    url: '/user/favorites'
  })
}
// 已发布房源列表
export const PublishHouseListRequest = () => {
  return request({
    url: '/user/houses'
  })
}
